'use strict'

let http = require('http')
let uuidV1 = require('uuid/v1');

//创建服务器
let server = http.createServer(function (req, res) {
    if (req.url === '/seckill-login' && req.method.toLowerCase() === 'post') {
        let alldata = ''
        req.on('data', function (chunk) {
            alldata += chunk
        })

        req.on('end', function () {
            console.log(alldata)
            let result = {}
            result["token"] = uuidV1()
            res.end(JSON.stringify(result))
        })
    }
})

//设置监听端口
server.listen(4000, function () {
    console.log("server is started listen port 4000")
})